
             
/**
 * 
 *
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file. 
 *
 * @File name:  QueryTNavKeywordByPIDAction.java   查询【首页类目搜索关键字表:T_NAV_KEYWORD】
 * @Create on:  2012-11-07 21:26:350
 * @Author      :  高宇舟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
package com.boho.ecp.base.action;

            
import java.sql.Connection;
import java.util.List;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.service.MessageService;

import com.boho.ecp.base.cache.TNavKeywordCache;
import com.boho.ecp.po.TNavKeywordPO;
public class QueryTNavKeywordByPIDAction extends ActionImp {
	private Connection con=null;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		atx.setErrorContext("EC_COMMON_1004", MessageService.getMessage("EC_COMMON_1004"),"【首页类目搜索关键字表:T_NAV_KEYWORD|】" ,ex);
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		Integer pKeywordId = atx.getIntegerValue("P_KEYWORD_ID");
		List list = TNavKeywordCache.queryTNavKeywordByPID(con, pKeywordId, 1);
		for (int i=0, j=list.size(); i<j; i++) {
			DynaBeanMap dbm = (DynaBeanMap) list.get(i);
			int keywordId = Integer.parseInt(dbm.get("KEYWORD_ID")+"");
			List<TNavKeywordPO> childList = TNavKeywordCache.queryTNavKeywordForTreeMode(con, keywordId, 3);
			dbm.put("KEYWORD_CHILDS", childList);
//			if (Integer.parseInt(dbm.get("P_KEYWORD_ID")+"") == Product.KEYWORD_ROOT) {
//				List<TBrandPO> brandList = TCategoryBrandCache.queryTCategoryBrandByCategoryID(con, keywordId);
//				dbm.put("BRAND_LIST", brandList);
//			}
			list.set(i, dbm);
		}
		
		atx.setValue("T_NAV_KEYWORD", list.toArray());
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		return 1;
	}
}
